#include <iostream>
#include <string>
#include <fstream>
#include <jsoncpp/json/json.h>

struct Student
{
    void debug()
    {
        std::cout << name << std::endl << age << std::endl << sex << std::endl;
    }
    std::string name;
    int age;
    std::string sex;
};
// int main()
// {
//     std::ofstream of("Student.txt");
//     Student s1 = {"Lina", 20, "male"};
//     Json::Value root;
//     root["name"] = s1.name;
//     root["age"] = s1.age;
//     root["sex"] = s1.sex;
//     Json::FastWriter writer;
//     std::string str = writer.write(root);
//     of << str;
// }

int main()
{
    std::ifstream ifs("Student.txt");
    std::string json_str;
    ifs >> json_str;
    Json::Reader reader;
    Json::Value root;
    reader.parse(json_str, root);
    Student s;
    s.name = root["name"].asString();
    s.age = root["age"].asInt();
    s.sex = root["sex"].asString();
    s.debug();
}